from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https:www.baidu.com')
# css定位,id选择器
# kw = driver.find_element(By.CSS_SELECTOR, '#kw')
# print(kw.get_attribute('outerHTML'))

# css定位,class选择器
# kw = driver.find_element(By.CSS_SELECTOR, '.s_ipt')
# print(kw.get_attribute('outerHTML'))

# css定位,后代选择器
# kw = driver.find_element(By.CSS_SELECTOR, '#form input')
# print(kw.get_attribute('outerHTML'))

# 子元素选择器
# kw = driver.find_element(By.CSS_SELECTOR, '#form>input')
# print(kw.get_attribute('outerHTML'))

# 并集标签选择器
# kw = driver.find_element(By.CSS_SELECTOR, 'input.s_ipt')
# print(kw.get_attribute('outerHTML'))

# input[id="kw"]
# kw = driver.find_element(By.CSS_SELECTOR, 'input[id="kw"]')
# print(kw.get_attribute('outerHTML'))

# nth-child()
kw = driver.find_element(By.CSS_SELECTOR, '#form>input:nth-child(11)')
print(kw.get_attribute('outerHTML'))

# 关闭浏览器
driver.quit()
